﻿using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.Package;
using Model.RF.Package;

namespace DAL.RF.Package
{
    public class UnpackfromBox : BaseRepository_DT<UnpackfromBoxInfo>, IUnpackfromBox
    {
        #region 静态变量部分
        private const string PARM_UNPACKFROMBOX_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_UNPACKFROMBOX_USERID = "@UserID";
        private const string PARM_UNPACKFROMBOX_PCIP = "@PCIP";
        #endregion


        public bool UnpackfromBox_Insert(UnpackfromBoxInfo ui, string packageProductSN)
        {
            SqlParameter[] Parms = GetParameters();
            SetAllParameters(ui,packageProductSN, Parms);

            SqlCommand cmd = new SqlCommand();
            foreach (SqlParameter parm in Parms)
                cmd.Parameters.Add(parm);

            using (SqlConnection conn = new SqlConnection(sqlHelper.ConnectionStringLocalTransaction))
            {
                conn.Open();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "UnpackfromBox_Insert";
                using (SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { }
                return true;
            }
        }

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_UNPACKFROMBOX_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 100),
					new SqlParameter(PARM_UNPACKFROMBOX_USERID, SqlDbType.NVarChar, 10),
                    new SqlParameter(PARM_UNPACKFROMBOX_PCIP,SqlDbType.NVarChar,50)

                };
            return parms;
        }

        public void SetAllParameters(UnpackfromBoxInfo ad,string packageProductSN, params SqlParameter[] Parms)
        {
            Parms[0].Value = packageProductSN;
            Parms[1].Value = ad.UserID;
            Parms[2].Value = ad.PCIP;
        }
        #endregion
    }
}
